home *** CD-ROM | disk | FTP | other *** search
- # include "BlobMgr.h"
-
-
- /*
- * Shuffle the locations of the blobs in the given set. If it is
- * undesirable to show all the redrawing that takes place during
- * this, HideBlobSet() should be called before ShuffleBlobSet(), and
- * ShowBlobSet() after.
- *
- * ShuffleBlobSet() deals with the following problem. Suppose two blobs
- * to be switched are both visible. The first is moved, i.e., hidden
- * and redrawn at the location of the second. Then the second is moved,
- * i.e., hidden and redrawn at the previous location of the first.
- * But moving the second blob erases the newly drawn first blob! To
- * avoid this, ShuffleBlobset() hides the first blob before moving them,
- * and redraws it afterward.
-
- * ShuffleBlobSet() usually results in an update event being generated
- * since hiding a blob adds its region to the update region for the
- * window. ValidRect() can be called (with the window's portRect)
- * to defeat it.
- *
- * The static region is often empty, which is why the drag regions are used
- * to determine the offsets.
- */
-
- pascal void
- ShuffleBlobSet (BlobSetHandle bSet)
- {
- BlobHandle b1, b2;
- short size, h, v;
- Boolean vis1 = false;
-
- size = BlobSetSize (bSet);
- for (b1 = FirstBlob (bSet); b1 != nil; b1 = NextBlob (b1))
- {
- b2 = GetBlobHandle (bSet, BlobRand (size - 1));
- h = BDragBox (b1).left - BDragBox (b2).left;
- v = BDragBox (b1).top - BDragBox (b2).top;
- if (BlobEnabled (b1))
- {
- HideBlob (b1);
- vis1 = true;
- }
- OffsetBlob (b1, inFullBlob, -h, -v);
- OffsetBlob (b2, inFullBlob, h, v);
- if (vis1)
- ShowBlob (b1);
- }
- }
-
-
- /*
- * Shuffle the globs attached to the blobs in the given set.
- */
-
- pascal void
- ShuffleGlobSet (BlobSetHandle bSet)
- {
- BlobHandle b;
- short size;
-
- size = BlobSetSize (bSet);
- for (b = FirstBlob (bSet); b != nil; b = NextBlob (b))
- {
- SwapGlob (b, GetBlobHandle (bSet, BlobRand (size-1)));
- }
- }
-